package com.eleadmin.order.service.impl;

import com.eleadmin.damon.utils.results.PageResult2;
import com.eleadmin.common.core.web.JsonResult;
import com.eleadmin.common.system.entity.User;
import com.eleadmin.order.service.UserService2;
import org.springframework.stereotype.Service;
import com.eleadmin.order.biz.UserBiz2;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户服务实现类
 *
 * @author : Doman
 * @version ：1.0
 * @date : 2023-04-21 10:42:44
 */
@Service
public class UserServiceImpl2 /*extends ServiceImpl<UserMapper, User> */ implements UserService2 {

    @Autowired
    private UserBiz2 userBiz;

    @Override
    public JsonResult list(PageResult2<T> page, User user, User loginUser) throws Exception {
        return userBiz.list(page, user, loginUser);
    }

    @Override
    public JsonResult list(User user, User loginUser) {
        return JsonResult.ok().setData(userBiz.list(user, loginUser));
    }

    @Override
    public JsonResult getById(String id) {
        return JsonResult.ok().setData(userBiz.getById(id));
    }

    @Transactional
    @Override
    public JsonResult save(User user, User loginUser) {
        userBiz.save(user, loginUser);
        return JsonResult.ok("添加成功");
    }

    @Transactional
    @Override
    public JsonResult update(User user, User loginUser) {
        if (userBiz.update(user, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public void updateGzhId(User user) {
        userBiz.updateGzhId(user);
    }

    @Transactional
    @Override
    public JsonResult remove(String id, User loginUser) {
        if (userBiz.remove(id, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
